package com.cskaoyan.service;

import com.cskaoyan.dao.UserDao;
import com.cskaoyan.dao.UserDaoImpl;

/**
 * @author stone
 * @date 2022/08/26 15:20
 */
public class UserServiceImpl implements UserService{

    //UserDao userDao = new UserDaoImpl(); //应用程序生成 → 通过Spring容器获得 → set方法
    UserDao userDao;

    public void setUserDao(UserDao userDao) {
        // set方法形参 → 让他能够执行到set方法，set方法需要的形参
        // 是从Spring容器中获得
        this.userDao = userDao;
    }

    @Override
    public void methodA() {
        System.out.println("hello userServiceImpl");
        userDao.method1();//如果取出，则输出hello userdao；如果没取出，空指针异常
    }
}
